package com.qwt.part_time_api.utils;

import com.qwt.part_time_api.pojo.Task;
import com.qwt.part_time_api.vo.SuggestionVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 君子慎独
 * @create 2022/1/2 0002 18:53
 * 用于实体类 和 视图类 之间的数据交换
 */
@Slf4j
public class Copy {

    public static List<SuggestionVo> copySuggestion(List<Task> list) {
        ArrayList<SuggestionVo> suggestionVo = new ArrayList<>();
        for (Task record : list) {
            suggestionVo.add(copy(record, true));
        }
        return suggestionVo;
    }

    public static SuggestionVo copy(Task article, boolean flag) {
        SuggestionVo suggestionVo = new SuggestionVo();
        //属性相同进行 复制
        BeanUtils.copyProperties(article, suggestionVo);
        return suggestionVo;
    }
}
